﻿using System;
using System.Globalization;
using System.Text;
using System.Collections.Generic;
using System.Linq;

using Microsoft.VisualStudio.TestTools.UnitTesting;

using ProjectBase.Core;
using $prjsn$.Entity;
using $prjsn$.Entity.Services;
using $prjsn$.Entity.Services.HowTos;

namespace $safeprojectname$.Core.Persistent
{
    [TestClass]
    public class PersistentFunctionalityTest : TestBase
    {
        [TestMethod]
        public void GetImplementationOfInterface_Passed()
        {
            var list = new List<IPersistentObject>
            {
                new Lang(),
                new Translator(),
                new Phrase(),
                new User(),
                new Member(),
                new ArticleCategory(),
                new ArticleGroup(),
                new Article(),
                new ComplexEntity(),
                new SimpleEntity(),
            };

            // order by HashCode explicitly
            var hashes = list.OrderBy(e => e.GetHashCode());
            var withMinHasCode = hashes.First();
            var withMaxHasCode = hashes.Last();

            // order by HashCode IComparable
            var ordered = list.OrderBy(e => e);
            var first = ordered.First();
            var last = ordered.Last();

            // Check the results
            Assert.IsTrue(first == withMinHasCode, first.GetType().Name);
            Assert.IsTrue(last == withMaxHasCode, last.GetType().Name);
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        [TestInitialize]
        public override void MyTestInitialize()
        {
            base.MyTestInitialize(); // Use TestInitialize to run code before running each test
        }

        [TestCleanup]
        public override void MyTestCleanup()
        {
            base.MyTestCleanup(); // Use TestCleanup to run code after each test has run
        }
        #endregion
    }
}
